import React, { Component } from 'react';
import WPT, { onTouchEnd } from 'wpt';

import './index.less';

const API = {
    index: '//api.weipaitang.com/*',
};

export default class Index extends Component {
    constructor(props) {
        super(props);
        WPT.getData(API.index, {}, res => {
            if (res.code !== 0) {
                WPT.Modal.alert(res.msg);
                return;
            }
            this.setState({ code: res.code });
        });
    }

    state = {
        code: 0,
    };

    componentDidMount() {}

    handelSelect = () => {};

    setCode = (xx, dd) => () => {
        this.setState({
            code: xx,
            // ddd: dd,
        });
    };

    render() {
        const { code } = this.state;
        return (
            <div className="page-*">
                <button {...onTouchEnd(this.handelSelect)}>{code}</button>
                <button {...onTouchEnd(this.setCode(code))}>{code}</button>
                <img width="200px" src="https://cdn.weipaitang.com/static/public/202009085ede9e44-82ff-9e4482ff-53d0-9b510610c31f.svg" />
            </div>
        );
    }
}
